package cn.study;

import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugin.logging.Log;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;

/**
 * @author: xiongfei
 * @date: 2025-06-17
 */
@Mojo(name = "world", requiresProject = false, defaultPhase = LifecyclePhase.PROCESS_SOURCES)
public class MyAnnotationMojo extends AbstractMojo {
    @Parameter(defaultValue = "${project}")
    private MavenProject mavenProject;

    @Parameter(required = true)
    private String name;

    @Parameter(required = false)
    private String num;

    @Override
    public void execute() throws MojoExecutionException, MojoFailureException {
        Log log = getLog();
        log.info("Hello maven, This is my Second plugin.");
        log.info("这个项目的名字:" +mavenProject.getBuild().getFinalName());
        log.info("name的值:" +name);
        log.info("num的值:" +num);
    }
}
